# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.

pkgname=rtfm
pkgver=95.a807a80
pkgrel=5
pkgdesc='A database of common, interesting or useful commands, in one handy referable form.'
groups=('blackarch' 'blackarch-misc')
arch=('any')
url='https://github.com/leostat/rtfm'
license=('custom:unknown')
depends=('python' 'python-terminaltables' 'python-urllib3')
makedepends=('git')
source=("git+https://github.com/leostat/$pkgname.git")
md5sums=('SKIP')

pkgver() {
  cd $pkgname

  echo $(git rev-list --count HEAD).$(git rev-parse --short HEAD)
}

package() {
  cd $pkgname

  install -dm 755 "$pkgdir/usr/bin"
  install -dm 755 "$pkgdir/usr/share/$pkgname"

  install -Dm 755 "$pkgname.py" "$pkgdir/usr/share/$pkgname/"
  install -Dm 644 *.sql "$pkgdir/usr/share/$pkgname/"
  install -Dm 644 -t "$pkgdir/usr/share/doc/$pkgname/" README.md

  cat >> "$pkgdir/usr/bin/$pkgname" << EOF
#!/bin/sh
cd /usr/share/$pkgname
exec python $pkgname.py "\$@"
EOF

  chmod +x "$pkgdir/usr/bin/$pkgname"
}

